import React,{Component} from "react";

class Child extends Component<any,any>{
    click=()=>{
        console.log(this.props); 
        this.props.fn('7777')
    }
    render(){
        return(
            <fieldset>
                <legend>Zi</legend>
                <button onClick={this.click}>点击子</button>
            </fieldset>
        )
    }
}

class Parent extends Component<any,any>{
    state ={
        msg:''
    }
    child=React.createRef<Child>()
    handleClick=(params:any)=>{
        console.log(params); 
        this.setState({msg: params})
        console.log(this.child);
        
    }
    render() {
        return(
            <fieldset>
                <legend>fu</legend>
                <Child ref={this.child} fn={this.handleClick}/>
                <button>点击</button>
                <h1>{this.state.msg}</h1>
            </fieldset>
        )
    }
}

export default Parent